package com.darren.framework.dao;

import com.alibaba.fastjson.JSONObject;
import com.darren.framework.bean.PageBean;
import com.darren.framework.entity.BaseEntity;

import java.io.Serializable;
import java.util.List;
import java.util.Map;


public interface GenericDao<T extends BaseEntity, PK extends Serializable> extends BaseDao {

    public Map<String, Object> constructHQLQuery(JSONObject queryJson);

    public T save(T entity);

    public T merge(T entity);

    public T findById(PK id);

    public T update(T entity);

    public void delete(T entity);

    public void deleteById(PK id);

    public List<T> getAll();

    /**
     * @param sql
     * @param pageSize
     * @param currentPage
     * @param objs
     * @return
     */
    public PageBean queryForPageBySQL(String sql, Integer pageSize, Integer currentPage, Object... objs);


    public List<T> queryByCondition(String hql, Object... objs);

    /**
     * @param hql
     * @param pageSize
     * @param currentPage
     * @param objs
     * @return
     */
    public PageBean queryForPageByHQL(String hql, Integer pageSize, Integer currentPage, Object... objs);

}